package view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.KeyEvent;
import android.widget.LinearLayout;

/**
 * Created by Administrator on 2017/6/5.
 */

public class MyWaitingDialog extends LinearLayout {
        private onBackDown onBackDown;

        public MyWaitingDialog(Context context) {
            super(context);
        }

        public MyWaitingDialog(Context context, AttributeSet attrs) {
            super(context, attrs);
        }

        public MyWaitingDialog(Context context, AttributeSet attrs, int defStyleAttr) {
            super(context, attrs, defStyleAttr);
        }

    @Override
        public boolean dispatchKeyEvent(KeyEvent event) {
            switch (event.getKeyCode()){
                case KeyEvent.KEYCODE_BACK:
                    if(onBackDown!=null){
                        onBackDown.onBackDown();
                    }
                    break;
                default:
                    break;
            }
            return super.dispatchKeyEvent(event);
        }
        public void setOnBackDown(MyWaitingDialog.onBackDown onBackDown) {
            this.onBackDown = onBackDown;
        }

        public interface onBackDown{
            void onBackDown();
        }
}
